# -*- coding:utf-8 -*-

# -*- coding:utf-8 -*-
from django.db.models import CharField, BooleanField, TextField, ForeignKey,CASCADE
from Apps.common.custommodel import CustomModel
from Apps.common.fields import UserForeignKeyField
from Apps.user.models import User


class SystemUserLoginInfo(CustomModel):
    userid = CharField(max_length=150, verbose_name="成员UserID")
    username = CharField(max_length=150, verbose_name='登陆用户名')
    browser = CharField(max_length=64, verbose_name="浏览器")
    ipaddr = CharField(max_length=32, verbose_name="ip地址", null=True, blank=True)
    device = CharField(max_length=64, verbose_name="登陆设备", null=True, blank=True)
    loginLocation = CharField(max_length=64, verbose_name="登录位置", null=True, blank=True)
    msg = CharField(max_length=32, verbose_name="操作信息", null=True, blank=True)
    os = CharField(max_length=32, verbose_name="操作系统", null=True, blank=True)
    login_type = CharField(max_length=16, verbose_name='登陆方式(密码登陆，扫码登陆)')
    status = CharField(max_length=32, verbose_name="登陆状态(登陆成功，登陆失败)")
    losePassword = CharField(max_length=128, verbose_name='登陆失败时，输入的密码')

    class Meta:
        db_table = "systemloginlog"
        verbose_name = '登录日志'
        verbose_name_plural = verbose_name
        ordering = ('-create_time',)

    def __str__(self):
        return f"{self.username}"
